<%@page import="entities.Link"%>
<%@page import="systems.ConfigSystem"%>
<%@page import="entities.SiteConfig"%>
<%@page import="java.util.List"%>
<%@page import="entities.Category"%>
<%@page import="helpers.UrlHelper"%>
<%
	Category category = (Category) request.getAttribute("category");
	List<Category> categories = (List<Category>) request.getAttribute("categories");
	List<Category> parents = (List<Category>) request.getAttribute("parents");
	
	List<Link> links = (List<Link>) request.getAttribute("links");
	SiteConfig siteConfig = ConfigSystem.getConfigs();
%>
<jsp:include page="/demo/layouts/header.jsp" />
    
		<h2 class="title">Photography</h2>
		<div class="dir">
			<a href="/home">Directory</a>
			<% 
			for (int i = 0; i < parents.size(); i++) {
				if (i < parents.size() - 1) {
			%>
			 > <a href="/category/<%=parents.get(i).getId()%>"><%=parents.get(i).getName() %></a>
			<%	} else { %>
			 > <%=parents.get(i).getName() %>
			<% 
				}
			} %>
		</div>
		<% if (categories.size() > 0) { %>
		<div class="directories">
			<h2>Categories</h2>
			<table width="100%">
				<tr>
					<td>
						
						<ul>
							<% for (int i=0; i < (categories.size()/2 + categories.size()%2); i++) { %>
							<li><a href="/category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a> (<%=categories.get(i).getCount() %>)</li>
							<% } %>
						</ul>
					</td>
					<td>
						<ul>
							<% 
							if (categories.size() > 1) {
								for (int i = (categories.size()/2 + categories.size()%2); i < categories.size(); i++ ) {
							%>
							<li><a href="/category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a> (<%=categories.get(i).getCount() %>)</li>
							<% 
								}
							} %>
						</ul>
					</td>
				</tr>
			</table>
		</div>
		<br />
		<% } %>
		
		<% if (links.size() > 0) { %>
		<div class="links">
			<h2>Links</h2>
			<ul>
				<% for (int i = 0; i < links.size(); i++) { %>
				<li>
					<a href="http://<%=links.get(i).getUrl()%>"><%=links.get(i).getName() %></a>
					<br />
					<%=links.get(i).getDescription() %>
					<br />
					<font color="green">linkdirectory.com/category</font>
				</li>
				<% } %>
			</ul>
		</div>
		<% } %>
<jsp:include page="/demo/layouts/footer.jsp" />
    